<!-- templates/test.html -->
{% extends 'base.html' %}

{% block title %}测试页面{% endblock %}

{% block content %}
<div class="auth-container">
    <h1>JavaScript测试</h1>
    <div id="test-message" class="message"></div>
    
    <button onclick="testJavaScript()">测试JavaScript</button>
    <button onclick="testCSRF()">测试CSRF</button>
    <button onclick="testFetch()">测试Fetch</button>
    
    <script>
        function testJavaScript() {
            alert('JavaScript工作正常!');
            console.log('JavaScript工作正常!');
        }
        
        function testCSRF() {
            const token = getCSRFToken();
            console.log('CSRF Token:', token);
            alert('CSRF Token: ' + token);
        }
        
        function testFetch() {
            console.log('开始测试Fetch...');
            fetch('/user/login/', {
                method: 'GET'
            })
            .then(response => {
                console.log('Fetch响应:', response.status);
                alert('Fetch测试成功: ' + response.status);
            })
            .catch(error => {
                console.error('Fetch错误:', error);
                alert('Fetch测试失败: ' + error.message);
            });
        }
    </script>
</div>
{% endblock %}